
import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.application


var buttons = arrayOf(
    arrayOf("%","C","<-","/"),
    arrayOf("7","8","9","*"),
    arrayOf("4","5","6","-"),
    arrayOf("1","2","3","+"),
    arrayOf("CE",".","0","=")
) //按钮组

@Composable
fun showScreen() {
    var expression by remember { mutableStateOf("0") } //表达式
    MaterialTheme {
        Card (
            modifier = Modifier
                .fillMaxWidth()
                .padding(15.dp) // 外边距
                .clickable { }
                .background(Color.White),
            elevation = 10.dp // 设置阴影
        ){
            Column(
                modifier = Modifier.verticalScroll(ScrollState(0)).fillMaxWidth().height(80.dp).background(Color.White),
            ) {
                TextField(
                    value = expression,
                    onValueChange = { expression = it },
                    modifier = Modifier.fillMaxWidth(),
                    textStyle = TextStyle(color = Color.Black, fontStyle = FontStyle.Normal, fontSize = 42.sp, textAlign = TextAlign.End),
                    readOnly = true,
                    maxLines = 1,
                    singleLine = true,
                    colors = TextFieldDefaults.textFieldColors(
                        backgroundColor = Color.White,
                        disabledIndicatorColor = Color.Transparent,
                        focusedIndicatorColor = Color.Transparent,
                        unfocusedIndicatorColor = Color.Transparent,
                    )
                )
            }
        }
    }
}

@Composable
fun ShowButtonGroups() {
    MaterialTheme {
        Row {
            for (button in buttons) {
                Column {
                    for (textVal in button) {
                        Button(
                            onClick = {

                            }
                        ){
                            Text(textVal)
                        }
                    }

                }
            }
        }
    }
}


fun main() = application {
    Window(onCloseRequest = ::exitApplication) {
        showScreen()//显示屏幕
        ShowButtonGroups()//显示按钮
    }
}
